package com.ruoyi.service.impl;

import com.ruoyi.domain.BaerUserEq;
import com.ruoyi.domain.EquipmentInfo;
import com.ruoyi.domain.TaskEq;
import com.ruoyi.mapper.BaseUserEqMapper;
import com.ruoyi.service.BaseUserEqService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class BaseUserEqServiceImpl implements BaseUserEqService {

    @Autowired
    private BaseUserEqMapper baseUserEqMapper;

    @Override
    public BaerUserEq queryUserInfo(Long userId, String loadingId) {

        String userIds = String.valueOf(userId);
        List<TaskEq> taskEqList = baseUserEqMapper.queryTaskEq(loadingId,userIds);
        List<BaerUserEq> baerUserEqList = baseUserEqMapper.queryUser(userId);
        BaerUserEq baerUserEq = new BaerUserEq();
        if(taskEqList.size() > 0){
            if(baerUserEqList.size() > 0){
                baerUserEq = baerUserEqList.get(0);
            }
            baerUserEq.setTaskEqList(taskEqList);
        }
        return baerUserEq;
    }

    @Override
    public EquipmentInfo queryEquipmentInfo(String loadingId, Long equipmentid) {
        List<EquipmentInfo> equipmentInfos = baseUserEqMapper.queryEquipmentInfo(loadingId,equipmentid);
        EquipmentInfo equipmentInfo = new EquipmentInfo();
        if(equipmentInfos.size() > 0){
            equipmentInfo = equipmentInfos.get(0);
        }
        return equipmentInfo;
    }
}
